<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">{$web_data['web_title']}</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive">
                <div class="input-group input-group">
                   <input id="qrcode_content" type="text" placeholder="输入网址或文字" class="form-control">
                    <span class="input-group-btn">
                      <button type="button" onclick="create_qrcode()" class="btn btn-info btn-flat">生成</button>
                    </span>
                </div>

                <div class="col-md-12" style="text-align: center">
                    <img class="img-responsive pad" id="qrcode_result" src="" alt="">
                </div>

            </div>

            <script>
                function create_qrcode() {
                    var qrcode_content = $("#qrcode_content").val();

                    $.ajax({
                        url: 'index.html',
                        type: "post",
                        data: {
                            qrcode_content:qrcode_content
                        },
                        dataType: 'json',
                        cache: false,
                        success: function (data) {
                            console.log(data);
                            $("#qrcode_result").attr('src',data.result.url+"?"+img_name_random());
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            console.log("系统异常，请稍后重试");
                        }
                    });
                }

                //图片后缀随机数
                function img_name_random() {
                    var rand_one = parseInt(100*Math.random());
                    var rand_two = parseInt(100*Math.random());
                    return String(rand_one)+String(rand_two);
                }
            </script>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>

